package main

import "fmt"

func FindPairsPos(list []int) []int {
	pos := []int{}
	length := len(list) - 1
	for i := 0; i < length; i++ {
		if list[i] == list[i+1] {
			pos = append(pos, i)
			i++
		}
	}
	return pos
}

func FindTriPos(list []int) []int {
	pos := []int{}
	length := len(list) - 1

	for i := 0; i < length; i++ {
		if (i + 2) > length {
			// 剩余长度不够
			return pos
		} else {
			if list[i] == list[i+1] && list[i+1] == list[i+2] {
				pos = append(pos, i)
				i += 2
			}
		}
	}

	return pos
}

func FindNseqPost(list []int, nseq int) []int {
	pos := []int{}
	length := len(list) - 1

	seqeq := func (list []int) bool {
		// 判断数组中元素是否都相同
		var listLength = len(list)

		if listLength <= 0 {
			return false
		} else if listLength == 1 {
			return true
		} else {
			// 多余 1 个元素
			var firstItem = list[0]
			for i := 1; i <= listLength; i++ {
				if list[i] != firstItem {
					return false
				}
			}
			return true
		}
	}

	for i := 0; i < length; i++ {
		if (i + nseq) > length {
			// 剩余长度不够
			return pos
		} else {
			if seqeq(list[i:i+nseq]) {
				pos = append(pos, i)
				i += 2
			}
		}
	}

	return pos
}

func FindExactPairs(list []int) []int {
	var pos = []int{}

	if len(list) < 2 {
		return pos
	}

	for i := 0; i < len(list) - 1; i++ {
		if list[i] == list[i+1] {
			if i+2 > len(list)-1 {
				pos = append(pos, i)
				return pos
			} else {
				// 这里需要同时满足
				if i-1 <= 0 {

				} else {

				}
			}
		}
	}

	return pos
}

func main() {
	//fmt.Println(FindPairsPos([]int{1,1,2,3,3,4,4,7,7,7}))
	//fmt.Println(FindTriPos([]int{1,1,2,3,3,4,4,7,7,7,1,9,9,9,9,9}))
	fmt.Println(FindExactPairs([]int{1,1,1,3,3}))
}